package cn.cq.admin.controller;

import cn.cq.admin.service.UploadService;
import cn.dev33.satoken.util.SaResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/oss")
public class UploadController {
    @Resource
    private UploadService uploadService;

    @PostMapping("/upload")
    public SaResult upload(@RequestParam("file") MultipartFile multipartFile) {
        String url = uploadService.uploadVideo(multipartFile);
        return SaResult.data(url);
    }

    @GetMapping("/getVideoAddress/{videoId}")
    public SaResult getVideoAddress(@PathVariable String videoId) {
        String address = uploadService.getVideoAddress(videoId);
        return SaResult.data(address);
    }
}
